home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / preview_arts.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-06-24  |  6.3 KB  |  237 lines

  1. function addLink(mc)
  2. {
  3.    Links[mc.link] = mc;
  4. }
  5. function getMCfromLink(Item)
  6. {
  7.    var _loc1_ = Item;
  8.    if(Links[_loc1_] == null)
  9.    {
  10.       var _loc2_ = [];
  11.       while(_loc1_ != sideMenu.ItemHome)
  12.       {
  13.          _loc2_.unshift(_loc1_._name.split("_").pop());
  14.          _loc1_ = _loc1_._parent._parent;
  15.       }
  16.       var _loc3_ = _loc2_.join("/");
  17.       Links[_loc1_] = Links[_loc3_];
  18.    }
  19.    return Links[_loc1_];
  20. }
  21. function removeLinkListener()
  22. {
  23.    Tardis.sideMenu.EB.removeListener(this);
  24. }
  25. function loadImage(mc, node, extrapath)
  26. {
  27.    var _loc3_ = extrapath;
  28.    if(_loc3_ == null)
  29.    {
  30.       _loc3_ = "";
  31.    }
  32.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  33.    var _loc1_ = node.firstChild.nodeValue;
  34.    var _loc2_ = node.attributes.path;
  35.    if(_loc2_ != null)
  36.    {
  37.       _loc1_ = _loc2_ + _loc1_;
  38.    }
  39.    else
  40.    {
  41.       _loc1_ = strDefaultPath + _loc3_ + _loc1_;
  42.    }
  43.    if(strPathPrefix == null)
  44.    {
  45.       strPathPrefix = "";
  46.    }
  47.    mc.loadMovie(strPathPrefix + _loc1_);
  48. }
  49. function build()
  50. {
  51.    var _loc2_ = Tardis.ActiveSection.id;
  52.    var _loc1_ = Tardis.Colors;
  53.    strSECTION_COLOR = _loc1_.getString(_loc2_);
  54.    SECTION_COLOR = _loc1_.getHex(_loc2_);
  55.    strSECTION_COLOR50 = _loc1_.getString(_loc2_ + "50");
  56.    SECTION_COLOR50 = _loc1_.getHex(_loc2_ + "50");
  57.    DEFAULT_COLOR = _loc1_.getHex("default");
  58.    DEFAULT_COLOR50 = _loc1_.getString("default50");
  59.    ndItems = nodeData.byName("items");
  60.    ndDefault = nodeData.byName("default");
  61.    if(nodeData.byName("image") != null)
  62.    {
  63.       loadImage(mc_img_0,nodeData.byName("image"),IMAGE_PATH);
  64.       intervalID = setInterval(checkLoad,300);
  65.    }
  66.    else
  67.    {
  68.       doOut();
  69.       _visible = true;
  70.    }
  71. }
  72. function checkLoad(movieClip)
  73. {
  74.    if(mc_img_0._height > 0)
  75.    {
  76.       doOut();
  77.       _visible = true;
  78.       clearInterval(intervalID);
  79.    }
  80. }
  81. function doOver(num)
  82. {
  83.    var _loc1_ = num;
  84.    if(!(_loc1_ == undefined || _loc1_ == null))
  85.    {
  86.       if(_loc1_ == "default")
  87.       {
  88.          populateRollText(ndDefault);
  89.       }
  90.       else
  91.       {
  92.          var _loc2_ = ndItems.childNodes[_loc1_];
  93.          populateRollText(_loc2_);
  94.       }
  95.    }
  96. }
  97. function doOut(num)
  98. {
  99.    populateRollText(ndDefault);
  100. }
  101. function populateRollText(node)
  102. {
  103.    var _loc1_ = node;
  104.    if(nodeData.byName("image") != null)
  105.    {
  106.       TEXT_POS = mc_img_0._height + 4;
  107.    }
  108.    else
  109.    {
  110.       TEXT_POS = 10;
  111.    }
  112.    titleFF.htmlText = "";
  113.    title2FF.htmlText = "";
  114.    bodyFF.htmlText = "";
  115.    body2FF.htmlText = "";
  116.    body3FF.htmlText = "";
  117.    PromoMC.contentFF.htmlText = "";
  118.    if(_loc1_.byName("title").getText() != null || _loc1_.byName("title2").getText() != null || _loc1_.byName("title3").getText() != null)
  119.    {
  120.       var _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + _loc1_.byName("title").getText() + " </FONT>";
  121.       _loc3_ += "<FONT COLOR=\"" + strSECTION_COLOR50 + "\"> " + _loc1_.byName("title2").getText() + " </FONT>";
  122.       _loc3_ += "<FONT COLOR=\"" + DEFAULT_COLOR50 + "\"> " + _loc1_.byName("title3").getText() + " </FONT>";
  123.       titleFF.htmlText = _loc3_;
  124.       titleFF.resize();
  125.       titleFF._y = TEXT_POS - 1;
  126.       TEXT_POS += titleFF._height - 4;
  127.    }
  128.    if(_loc1_.byName("byline").getText() != null)
  129.    {
  130.       title2FF.htmlText = _loc1_.byName("byline").getText();
  131.       title2FF.textColor = DEFAULT_COLOR;
  132.       title2FF.autosize = true;
  133.       title2FF._y = TEXT_POS;
  134.       TEXT_POS += title2FF._height - 4;
  135.    }
  136.    if(_loc1_.byName("body").getText() != null)
  137.    {
  138.       bodyFF.htmlText = parseBoldTags(_loc1_.byName("body").getText());
  139.       bodyFF.textColor = DEFAULT_COLOR;
  140.       bodyFF.resize();
  141.       bodyFF._y = TEXT_POS;
  142.       TEXT_POS += bodyFF._height + 7;
  143.    }
  144.    if(_loc1_.byName("body2").getText() != null)
  145.    {
  146.       body2FF.htmlText = _loc1_.byName("body2").getText();
  147.       body2FF.textColor = DEFAULT_COLOR;
  148.       body2FF.resize();
  149.       body2FF._y = TEXT_POS;
  150.       TEXT_POS += body2FF._height - 10;
  151.    }
  152.    if(_loc1_.byName("body3").getText() != null)
  153.    {
  154.       body3FF.htmlText = _loc1_.byName("body3").getText();
  155.       body3FF.textColor = SECTION_COLOR;
  156.       body3FF._y = TEXT_POS;
  157.    }
  158.    var _loc2_ = _loc1_.byName("bodylink");
  159.    if(_loc2_.byName("label").getText() != null)
  160.    {
  161.       bodyLinkMC._visible = true;
  162.       bodyLinkMC.arrowMC._visible = true;
  163.       bodyLinkMC.contentFF.htmlText = _loc2_.byName("label").getText();
  164.       bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  165.       bodyLinkMC.contentFF.autosize = true;
  166.       bodyLinkMC.navLink = false;
  167.       if(_loc2_.attributes.link != null)
  168.       {
  169.          bodyLinkMC.link = _loc2_.attributes.link;
  170.          bodyLinkMC.navLink = true;
  171.       }
  172.       else
  173.       {
  174.          bodyLinkMC.link = _loc2_.byName("link").getText();
  175.       }
  176.       bodyLinkMC.btn._width = bodyLinkMC.contentFF._width + bodyLinkMC.arrowMC._x - 20;
  177.       bodyLinkMC.btn.enabled = true;
  178.       bodyLinkMC.arrowMC._x = bodyLinkMC.contentFF._x + bodyLinkMC.contentFF._width + 3;
  179.    }
  180.    else
  181.    {
  182.       bodyLinkMC.arrowMC._visible = false;
  183.       bodyLinkMC._visible = false;
  184.       bodyLinkMC.btn.enabled = false;
  185.       bodyLinkMC.btn._width = 0;
  186.    }
  187. }
  188. function parseBoldTags(str)
  189. {
  190.    var _loc1_ = str;
  191.    var _loc2_ = _loc1_.indexOf("<b>");
  192.    if(_loc2_ != -1)
  193.    {
  194.       var _loc3_ = _loc1_.indexOf("</b>");
  195.       var word = _loc1_.substring(_loc2_ + 3,_loc3_);
  196.       var beginning = _loc1_.substring(0,_loc2_);
  197.       var end = _loc1_.substring(_loc3_ + 4);
  198.       return beginning + "<font face=\'FranklinGotURWTDem\'>" + word + "</font>" + parseBoldTags(end);
  199.    }
  200.    return _loc1_;
  201. }
  202. function txtOver(mc)
  203. {
  204.    Tardis.sideMenu.doOver(mc.link);
  205.    bodyLinkMC.arrowMC.gotoAndStop("over");
  206.    bodyLinkMC.contentFF.textColor = SECTION_COLOR;
  207. }
  208. function txtOut(mc)
  209. {
  210.    Tardis.sideMenu.doOut(mc.link);
  211.    bodyLinkMC.arrowMC.gotoAndStop("off");
  212.    bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  213. }
  214. function txtUp(mc)
  215. {
  216.    var _loc1_ = mc;
  217.    if(_loc1_.navLink)
  218.    {
  219.       Tardis.sideMenu.doUp(_loc1_.link);
  220.    }
  221.    else
  222.    {
  223.       Tardis.webPageOpen(_loc1_.link,"_blank");
  224.    }
  225. }
  226. Links = {};
  227. Tardis.sideMenu.EB.addListener(this);
  228. _visible = false;
  229. stop();
  230. onReady();
  231. this.onUnload = function()
  232. {
  233.    removeLinkListener();
  234.    clearInterval(intervalID);
  235.    this.onUnload = null;
  236. };
  237.